package com.peach.service.DeviceManage;

import com.peach.service.DeviceManage.PushMsgApplication;
import org.springframework.stereotype.Service;

@Service("PushMsgApplication")
public class PushMsgApplicationImpl implements PushMsgApplication{
    //安装应用程序
    public String prepareInstallAppPlist(String appId,String udid) {

        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \n");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n");
        backString.append("<plist version=\"1.0\">\n");
        backString.append("<dict>\n");
        backString.append("<key>Command</key>\n" );
        backString.append("<dict>\n");
        backString.append("<key>RequestType</key>\n");
        backString.append("<string>InstallApplication</string>\n");
        backString.append("<key>iTunesStoreID</key>");
        backString.append("<integer>"+ appId +"</integer>");
        backString.append("<key>ManagementFlags</key>\n");
        backString.append("<integer>1</integer>\n");
        backString.append("</dict>\n");
        backString.append("<key>CommandUUID</key>\n");
        backString.append("<string>installApp-"+udid+"</string>\n");
        backString.append("</dict>\n");
        backString.append("</plist>");
        return backString.toString();
    }
    //删除应用程序
    public String prepareRemoveAppPlist(String udid,String identifier) {

        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \n");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n");
        backString.append("<plist version=\"1.0\">\n");
        backString.append("<dict>\n");
        backString.append("<key>Command</key>\n" );
        backString.append("<dict>\n");
        backString.append("<key>RequestType</key>\n");
        backString.append("<string>RemoveApplication</string>\n");
        backString.append("<key>Identifier\n</key>");
        backString.append("<string>"+identifier+"</string>");
        backString.append("</dict>\n");
        backString.append("<key>CommandUUID</key>\n");
        backString.append("<string>removeApp-"+ udid +"</string>\n");
        backString.append("</dict>\n");
        backString.append("</plist>");
        return backString.toString();
    }
    //设备锁屏
    public String prepareDeviceLockPlist(String udid) {

        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
        backString.append("<plist version=\"1.0\"><dict><key>Command</key><dict><key>RequestType</key><string>");
        backString.append("DeviceLock");
        backString.append("</string><key>Message</key><string>");
        backString.append("");
        backString.append("</string><key>PhoneNumber</key><string>");
        backString.append("");
        backString.append("</string></dict><key>CommandUUID</key><string>");
        backString.append("deviceLock-"+ udid);
        backString.append("</string></dict></plist>");
        return backString.toString();
    }
    //查询设备已经安装的app列表
    public String prepareQueryInstalledAppPlist(String udid) {

        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \n");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n");
        backString.append("<plist version=\"1.0\">\n");
        backString.append("<dict>\n");
        backString.append("<key>Command</key>\n" );
        backString.append("<dict>\n");
        backString.append("<key>RequestType</key>\n");
        backString.append("<string>InstalledApplicationList</string>\n");
        backString.append("</dict>\n");
        backString.append("<key>CommandUUID</key>\n");
        backString.append("<string>queryInstalledApp-" + udid +"</string>\n\n");
        backString.append("</dict>\n");
        backString.append("</plist>");
        return backString.toString();
    }
    //开启丢失模式
    public String prepareLostModePlist(String udid){
//需要开启监管模式


        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
        backString.append("<plist version=\"1.0\">");
        backString.append("<dict>");
        backString.append("<key>Command</key>");
        backString.append("<dict>");
        backString.append("<key>RequestType</key>");
        backString.append("<string>DisableLostMode</string>");
//        backString.append("<key>Message</key>");
//        backString.append("<string>");
//        backString.append("把我的手机还给我");
//        backString.append("</string>");
        backString.append("</dict>");
        backString.append("<key>CommandUUID</key>");
        backString.append("<string>");
        backString.append("lostMode-" + udid);
        backString.append("</string>");
        backString.append("</dict>");
        backString.append("</plist>");
        return backString.toString();
    }
    //发出警报声
    public String prepareWarningVoicePlist (String udid) {


        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
        backString.append("<plist version=\"1.0\">");
        backString.append("<dict>");
        backString.append("<key>Command</key>");
        backString.append("<dict>");
        backString.append("<key>RequestType</key>");
        backString.append("<string>");
        backString.append("DeviceLocation");
        backString.append("</string>");
        backString.append("</dict>");
        backString.append("<key>CommandUUID</key>");
        backString.append("<string>");
        backString.append("warningVoice-" + udid);
        backString.append("</string>");
        backString.append("</dict>");
        backString.append("</plist>");
        return backString.toString();

    }

    //抹除设备数据
    public String prepareErasePlist (String pin,String udid) {


        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
        backString.append("<plist version=\"1.0\">");
        backString.append("<dict>");
        backString.append("<key>Command</key>");
        backString.append("<dict>");
        backString.append("<key>RequestType</key>");
        backString.append("<string>");
        backString.append("EraseDevice");
        backString.append("</string>");
        backString.append("<key>PIN</key>");
        backString.append("<string>");
        backString.append(pin);
        backString.append("</string>");
        backString.append("</dict>");
        backString.append("<key>CommandUUID</key>");
        backString.append("<string>");
        backString.append("erase-" + udid );
        backString.append("</string>");
        backString.append("</dict>");
        backString.append("</plist>");
        return backString.toString();

    }

    //查询相关信息
    public String prepareQueryPlist (String udid) {


        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
        backString.append("<plist version=\"1.0\">");
        backString.append("<dict>");
        backString.append("<key>Command</key>");
        backString.append("<dict>");
        backString.append("<key>RequestType</key>");
        backString.append("<string>");
        backString.append("DeviceInformation");
        backString.append("</string>");
        backString.append("<key>Queries</key>");
        backString.append("<array>");
        backString.append("<string>DeviceName</string>");
        backString.append("<string>ModelName</string>");
        backString.append("<string>OSVersion</string>");
        backString.append("<string>BatteryLevel</string>");
        backString.append("<string>SerialNumber</string>");
        backString.append("<string>IsMDMLostModeEnabled</string>");
        backString.append("<string>CurrentCarrierNetwork</string>");
        backString.append("<string>PhoneNumber</string>");
        backString.append("<string>ProductName</string>");
        backString.append("</array>");
        backString.append("</dict>");
        backString.append("<key>CommandUUID</key>");
        backString.append("<string>");
        backString.append("deviceDetail-"+ udid);
        backString.append("</string>");
        backString.append("</dict>");
        backString.append("</plist>");
        return backString.toString();

    }

    public String prepareCleanPasscodePlist (String udid,String unLockToken){
        StringBuffer backString = new StringBuffer();
        backString.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        backString.append("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \n");
        backString.append("\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n");
        backString.append("<plist version=\"1.0\">\n");
        backString.append("<dict>\n");
        backString.append("<key>Command</key>\n" );
        backString.append("<dict>\n");
        backString.append("<key>RequestType</key>\n");
        backString.append("<string>ClearPasscode</string>\n");
        backString.append("<key>UnlockToken\n</key>");
        backString.append("<string>"+unLockToken+"</string>");
        backString.append("</dict>\n");
        backString.append("<key>CommandUUID</key>\n");
        backString.append("<string>cleanPasscode-" + udid +"</string>\n\n");
        backString.append("</dict>\n");
        backString.append("</plist>");
        return backString.toString();
    }

}
